﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using SimpleExpressionEvaluator.Parser;

namespace SimpleExpressionEvaluator.Tests.Evaluation
{
    [TestFixture]
    public class OperatorsTextFixture
    {
        private ExpressionCompiler _eval;

        [SetUp]
        public void SetUp()
        {
            _eval = new ExpressionCompiler();
        }

        [Test]
        public void WillProperlyEvaluateSuccesfulRegexMatch()
        {
            string expr = @"three =~ ""One|Two|Three""";
            Assert.IsTrue(_eval.CompileExpression<bool>(expr).Evaluate(null));
        }

        [Test]
        public void WillProperlyEvaluateUnsuccesfulRegexMatch()
        {
            string expr = @"three =~ ""Four|Five|Six""";
            Assert.IsFalse(_eval.CompileExpression<bool>(expr).Evaluate(null));
        }

        [Test]
        public void WillProperlyEvaluateNegatedRegexMatch()
        {
            string expr = @"three !=~ ""One|Two|Three""";
            Assert.IsFalse(_eval.CompileExpression<bool>(expr).Evaluate(null));
        }

        [Test]
        public void WillProperlyEvaluateUnsuccesfulNegatedRegexMatch()
        {
            string expr = @"three !=~ ""Four|Five|Six""";
            Assert.IsTrue(_eval.CompileExpression<bool>(expr).Evaluate(null));
        }
    }
}
